#pragma once

#include "Protocol.hpp"

class NetCal
{
public:
    Response Execute(Request &req)
    {
        int x = req.GetX();
        int y = req.GetY();
        int oper = req.GetOper();

        Response resp(0, 0);

        switch (oper)
        {
        case '+':
            resp.SetResult(x + y);
            break;
        case '-':
            resp.SetResult(x - y);
            break;
        case '*':
            resp.SetResult(x * y);
            break;
        case '/':
            if (y == 0)
                resp.SetCode(1);
            else
                resp.SetResult(x / y);
            break;
        case '%':
            if (y == 0)
                resp.SetCode(2);
            else
                resp.SetResult(x % y);
            break;
        default:
            resp.SetCode(3);
            break;
        }
        
        return resp;
    }
};